var evalNumberId = getParameter("evalNumberId");
var uid = getParameter("uid");

$(function() {
	rt();
	
});

function rt(){
	
	var urlStr = serverPath + "/app/doctor/doctor/assess.do";
	var jsonStr = '{method:"metabolicSyndrome",requestlist:[{evalNumberId:"'+evalNumberId+'"}],  version:"1.0",uid:"'+uid+'", requestsource:"doctor"}' ;
	UseAjax(urlStr, jsonStr, document.cookie, metabolicSyndrome, '1');}


function metabolicSyndrome(nodeArrays) {
	var nodeArray=nodeArrays.resultlist[0];
	if (nodeArray && nodeArray.hypertensionreport
			&& nodeArray.knowledgebaseresult) {
		var wi = nodeArray.hypertensionreport;
		var kb = nodeArray.knowledgebaseresult;
		
		$("#futureRisk").show();

		$('#chart_title').html('您代谢综合征的评估结果为：' + kb.riskGrade);
		var text = '';
		if (kb.riskGrade == '高危人群') {
			text = text + '<center><img src="../../uiframe/images/daixieyellow.jpg" style="max-width: 100%;" /></center>';
		}
		if (kb.riskGrade == '低危人群') {
			text = text + '<center><img src="../../uiframe/images/daixiegreen.jpg" style="max-width: 100%;" /></center>';
		}
		if (kb.riskGrade == '代谢综合征') {
			text = text + '<center><img src="../../uiframe/images/daixiered.jpg" style="max-width: 100%;" /></center>';
		}
		text = text + '<ul>';
		text = text + '<li>';
		text = text + '具备以下5项组成成分中的3项或全部者为代谢综合征：' + '<br />';
		text = text + '1、超重和（或）肥胖　BMI≥25.0Kg/M²；' + '<br />';
		text = text + '2、高血糖　FPG≥6.1mmol/L（110mg/dl）和（或）餐后2小时血糖≥7.8 mmol/L（140mg/dl），和（或）已确诊糖尿病并治疗者；' + '<br />';
		text = text + '3、高血压　收缩压≥140mmHg 和（或） 舒张压≥90mmHg，和（或）已确诊高血压并治疗者；' + '<br />';
		text = text + '4、空腹血TG≥1.7 mmol/L（110mg/dl）' + '<br />';
		text = text + '5、空腹血HDL_C<0.9 mmol/L（35mg/dl）（男），<1.0 mmol/L（39mg/dl）（女）。' + '<br />';
		text = text + '</li>';
		text = text + '</ul>';
		$('#chart').html(text);

		text = '';

		text = text + '<h2>危险因素列表:</h2>';
	    text = text + '<table class="risk-list">';
	    text = text + '<tr><th class="th1">危险因素</th><th class="th2">您的情况</td><th class="th3 ">参考值</th></tr>';
	    text = text + '<tr><td>年龄</td><td>' + wi.age + '</td><td>随年龄增长风险增高</td></tr>';
	    if (wi.dm > 0) {
	    	text = text + '<tr class="high-light"><td>糖尿病史</td><td>有</td><td>无</td></tr>';
	    } else {
	    	text = text + '<tr><td>糖尿病史</td><td>无</td><td>无</td></tr>';
	    }
	    if (wi.hypertension > 0) {
	    	text = text + '<tr class="high-light"><td>高血压病史</td><td>有</td><td>无</td></tr>';
	    } else {
	    	text = text + '<tr><td>高血压病史</td><td>无</td><td>无</td></tr>';
	    }
		if (parseFloat(wi.systolic) >= 120) {
			text = text + '<tr class="high-light"><td>血压（收缩压）</td><td>' + wi.systolic + '</td><td><120mmHg</td></tr>';
		} else {
			if (parseFloat(wi.systolic) == 0) {
				text = text + '<tr><td>血压（收缩压）</td><td>未测量</td><td><120mmHg</td></tr>';
			} else {
				text = text + '<tr><td>血压（收缩压）</td><td>' + wi.systolic + '</td><td><120mmHg</td></tr>';
			}
		}
		if (parseFloat(wi.diastolic) >= 80) {
			text = text + '<tr class="high-light"><td>血压（舒张压）</td><td>' + wi.diastolic + '</td><td><80mmHg</td></tr>';
		} else {
			if (parseFloat(wi.diastolic) == 0) {
				text = text + '<tr><td>血压（舒张压）</td><td>未测量</td><td><80mmHg</td></tr>';
			} else {
				text = text + '<tr><td>血压（舒张压）</td><td>' + wi.diastolic + '</td><td><80mmHg</td></tr>';
			}
		}
		if (parseFloat(wi.bmi) < 18.5 || parseFloat(wi.bmi) >= 24) {
			text = text + '<tr class="high-light"><td>BMI</td><td>' + wi.bmi + '</td><td>18.5&le;BMI&lt;24</td></tr>';
		} else {
			text = text + '<tr><td>BMI</td><td>' + wi.bmi + '</td></td><td>18.5&le;BMI&lt;24</td></tr>';
		}
		if (parseFloat(wi.tg) >= 1.7) {
			text = text + '<tr class="high-light"><td>甘油三酯</td><td>' + wi.tg + '</td><td>&lt;1.7mmol/L</td></tr>';
		} else {
			if (parseFloat(wi.tg) == 0) {
				text = text + '<tr><td>甘油三酯</td><td>未测量</td><td>&lt;1.7mmol/L</td></tr>';
			} else {
				text = text + '<tr><td>甘油三酯</td><td>' + wi.tg + '</td><td>&lt;1.7mmol/L</td></tr>';
			}
		}
		if (wi.sex == 0) {
			if (parseFloat(wi.hdl) < 0.9 && parseFloat(wi.hdl) != 0) {
				text = text + '<tr class="high-light"><td>高密度脂蛋白胆固醇</td><td>' + wi.hdl + '</td><td>&ge;0.9mmol/L</td></tr>';
			} else {
				if (parseFloat(wi.hdl) == 0) {
					text = text + '<tr><td>高密度脂蛋白胆固醇</td><td>未测量</td><td>&ge;0.9mmol/L</td></tr>';
				} else {
					text = text + '<tr><td>高密度脂蛋白胆固醇</td><td>' + wi.hdl + '</td><td>&ge;0.9mmol/L</td></tr>';
				}
			}
		} else {
			if (parseFloat(wi.hdl) < 1.0 && parseFloat(wi.hdl) != 0) {
				text = text + '<tr class="high-light"><td>高密度脂蛋白胆固醇</td><td>' + wi.hdl + '</td><td>&ge;1.0 mmol/L</td></tr>';
			} else {
				if (parseFloat(wi.hdl) == 0) {
					text = text + '<tr><td>高密度脂蛋白胆固醇</td><td>未测量</td><td>&ge;1.0 mmol/L</td></tr>';
				} else {
					text = text + '<tr><td>高密度脂蛋白胆固醇</td><td>' + wi.hdl + '</td><td>&ge;1.0 mmol/L</td></tr>';
				}
			}
		}
		if ((parseFloat(wi.fastingbg) < 3.9 || parseFloat(wi.fastingbg) >= 6.1) && parseFloat(wi.fastingbg) != 0) {
			text = text + '<tr class="high-light"><td>空腹血糖</td><td>' + wi.fastingbg + '</td><td>3.9-6.1mmol/L</td></tr>';
		} else {
			if (parseFloat(wi.fastingbg) == 0) {
				text = text + '<tr><td>空腹血糖</td><td>未测量</td><td>3.9-6.1mmol/L</td></tr>';
			} else {
				text = text + '<tr><td>空腹血糖</td><td>' + wi.fastingbg + '</td><td>3.9-6.1mmol/L</td></tr>';
			}
			
		}
		if ((parseFloat(wi.postprandialbg) < 4.4 || parseFloat(wi.postprandialbg) >= 7.8) && parseFloat(wi.postprandialbg) != 0) {
			text = text + '<tr class="high-light"><td>餐后2小时血糖</td><td>' + wi.postprandialbg + '</td><td>4.4-7.8mmol/L</td></tr>';
		} else {
			if (parseFloat(wi.postprandialbg) == 0) {
				text = text + '<tr><td>餐后2小时血糖</td><td>未测量</td><td>4.4-7.8mmol/L</td></tr>';
			} else {
				text = text + '<tr><td>餐后2小时血糖</td><td>' + wi.postprandialbg + '</td><td>4.4-7.8mmol/L</td></tr>';
			}
		}
		
		text = text + '</table>';

		text = text + '<h2>风险提示：</h2>';
		text = text + '<ul>';
		text = text + '<li>' + kb.knowledgeBase1 + '</li>';
		if (kb.riskGrade == '代谢综合征') {
			text = text + '<li>' + kb.knowledgeBase2 + '患者；</li>';
		} else {
			text = text + '<li>' + kb.knowledgeBase2 + kb.riskGrade + '；</li>';
		}
		text = text + '<li>' + kb.knowledgeBase3 + wi.risks + '；</li>';
		text = text + '<li>' + kb.knowledgeBase4 + '</li>';
		text = text + '</ul>';

		$('#reportContent').html(text);
	} else {
		$('#chart_content').hide();
		$('#chart_title').hide();
		$('#reportContent').html(
			'<div><span style="font-size:16px;"><span style="color: rgb(105, 105, 105); "><span style="font-family: 黑体; ">没有记录</span></span></span></div>'
		);
	}
	
}
// 获取url参数
function getParameter(param) {
	var query = window.location.search;
	var iLen = param.length;
	var iStart = query.indexOf(param);
	if (iStart == -1)
		return "";
	iStart += iLen + 1;
	var iEnd = query.indexOf("&", iStart);
	if (iEnd == -1)
		return query.substring(iStart);
	return query.substring(iStart, iEnd);
}